home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / MISC / RF / RF.M < prev    next >
Encoding:
Text File  |  1995-04-17  |  7.2 KB  |  198 lines

  1. Ro=300; Rs=4; Co=.12 10^-12; gm=1/20; Cgs=.7 10^-12; Zo=50;        
  2. BeginPackage["RF`"]
  3.  
  4. p::usage="p[x,y] gives the impedance of x in parallel with y"
  5.  
  6. ToReal::usage="ToReal[x] gives the real and imageing parts of x"
  7.  
  8. AttenuationOfButterworth::usage="AttenuationOfButterworth[f, fc, k] gives
  9. the attenuation of a Butterworth filter with k elements, at f, if the -3.01dB
  10. frequency is fc"
  11.  
  12. Coax::usage = "Coax[r,R, Er] Gives the capacitance per metre, inductance
  13. per metre and characteristic impedance, of a coaxial cable of inner radius r,
  14. outer radius R, with a relative dielectric permittivity Er." 
  15.  
  16. InductanceOfCoil::usage="InductanceOfCoil[diameter, turns, length]
  17. calculates the inductance (in H) of a coil. Dimensions in mm, adapted 
  18. from ARRL manual, 1991, pp2-17"
  19.  
  20. InductanceOfStrip::usage="InductanceOfStrip[length, width, thickness]
  21. calculates the inductance (in H) of a flat strip. Dimensions in mm, adapted 
  22. from ARRL manual, 1991, pp2-20."
  23.  
  24.  
  25. InductanceOfWire::usage="InducatanceOfWire[radius, length] calculates the 
  26. inductance (in H) of a straight wire at low frequencies. Dimensions in mm.
  27. From 1991 ARRL manual."
  28.  
  29. MatchToFifty::usage="MatchToFifty[R, X] makes  a 50 resistor look like a given
  30. reactance R + I X. This designs a network that looks like R + i X. If the 
  31. circuit (say drain of FET) presents a + I b, then you will need a network that
  32. looks like a - I b for maximum power transfer.\n
  33. -----------X1-----------------\n
  34. |                 |\n
  35. |                 |\n
  36. 50                X2         <- R + i X\n
  37. |                 |\n
  38. |                 |\n
  39. -----------------------------\n"
  40.  
  41. ComplexLoad::usage="ComplexLoad[R0 (source) , X0 (source), r (load), r (load)] 
  42. matches a complex source to a complex load, where source < load, but see below. 
  43. Use a series reactance (X1) from source to load, and a parallel
  44. reactance (X2) across the load. I'm not sure of exactly what loads can 
  45. be matched. Note: This designs a network that looks like R + i X. If the
  46. circuit presents this, you probably want to enter R - i X. "
  47.  
  48.  
  49. RectangularCoax::usage="RectangularCoax[diameter,width,height,Er] calculates the 
  50. characteristic impedance of a rectangular coaxial line with a circular inner
  51. conductor. Uncertainty said to 0.5% for diameter/height <= 0.65. Source Handbook
  52. of Microwave and Optical Components, Volume 1, edited by K. Chang, 1989."
  53.  
  54. StripLine::usage ="StripLine[w,h,Er] gives the characteristic impedance of a
  55. stripline (double sided PCB, one side ground plane), given the width 'w' (m), height
  56. 'h' (m) and 'Er'  of the material. Source of data from 'The UHF Compendium'
  57. K. Weiner, Part 1 and 2, Verlag Rudolf Schmidt; correction marked in my copy.
  58. Note: As long as 'w' and 'h' are given in the same units, they can be mm,
  59. m, inches etc."
  60.  
  61. SMESFET::usage="SMESFET[freq,Zo,Rs,Cgs,Ro,Co,gm] gives the 4 S parameters
  62. S11, S12, S21 and S22 of a unilateral MESFET (hence S12=0), using the 
  63. equivalent circuit in my MSc notes. All units are SI"
  64.  
  65.  
  66. TerminatedLine::usage ="TerminatedLine[Zo,Zl,B,l] calculates the impedance of a 
  67. terminated line, length l (m), propagation constant B, of characteristic impedance
  68. Zo terminated in Zl"
  69.  
  70. TwinWire::usage = "TwinWire[d,s,Er] Gives the capacitance per metre, inductance
  71. per metre and characteristic impedance of  two parallel wires, of diameter d,
  72. spaced s apart, with a relative dielectric permittivity Er."
  73.  
  74. UnknownC::usage="UnknownC[freq, Zo, length, type] gives the capacitance (in pF)
  75. required to resonate a line of length 'length' (m) with characteristic impedance
  76. 'Zo' of 'type'  'Short' or 'Open' at a frequency of 'freq' (MHz)."
  77.  
  78.  
  79. Begin["`Private`"] 
  80.  
  81. p[x_, y_]:= (x y )/(x + y)
  82.  
  83. AttenuationOfButterworth[f_, fc_, k_]:=10 Log[10, (1+ (f/fc)^(2 k) )] //N 
  84. Coax[r_, R_, Er_] := 
  85.      Block[{c, l,z},
  86.         c = N[2 Pi  8.8542 10^-12 Er/ Log[R/r]];
  87.         l = N[2 10^-7 Log[R/r]];
  88.         z = Sqrt[l/c];
  89.         Return[{c "F/m",l "H/m",z "Ohms"}]
  90.        ]
  91. InductanceOfStrip[B_, W_, H_]:=
  92.       Block[{},
  93.            b=B/25.4; (* Original formula assumes inches *)
  94.            w=W/25.4;
  95.            h=H/25.4;
  96.            N[0.00505 10^-6  b (Log[2 b / (w + h)] + .5 + .2235(w + h) / b)]
  97.       ]
  98.  
  99. ToReal[x_]:=
  100.         Block[ {a,b,c},
  101.         a=Numerator[x] * Conjugate[ Denominator[x]];
  102.         b=Expand[ Denominator[x] * Conjugate[ Denominator[x]]];
  103.         Print[a];
  104.         Print[b];
  105.         c=a/b;
  106.         Return[c]
  107.         ]
  108.  
  109. InductanceOfCoil[D_, n_, L_]:=
  110.       Block[{},
  111.            d=D/25.4;
  112.            l=L/25.4;
  113.            If[ l < 0.4 d, Print["Formulae may show significant errors"]];
  114.            N[ 10^-6 d^2 n^2 / (18 d + 40 l)]
  115.       ]
  116.  
  117. InductanceOfWire[a_, b_]:=N[10^-6 0.0002 b ( Log[2 b / a] - .75)]
  118.  
  119. MatchToFifty[r_, x_]:=
  120.       Block[{d},
  121.       d=50^2 + (X1+X2)^2;
  122.       NSolve[{r==50 X2^2  / d, x== (2500 X2 + X1^2 X2 + X1 X2^2) /d },{X1,X2}]
  123.       ]
  124.  
  125. ComplexLoad[R0_, X0_, r_, x_]:=
  126.       Block[{d},
  127.       d=R0^2 +(X0+X1+X2)^2;
  128.       NSolve[{r==-(X0 X2+X1 X2)  / d, x== (R0 X2) /d },{X1,X2}]
  129.       ]
  130.  
  131. RectangularCoax[d_Positive, ww_, bb_, Er_]:= 
  132.      Block[{A,B,w,b},
  133.       If[ ww < bb,
  134.            temp=bb; b=ww; w=temp; 
  135.       ,w=ww;b=bb;
  136.       ];
  137.       B=Tanh[2.2 (w/b - 1.0)];
  138.       A=(10 - 2.1(d/b)^3) B;
  139.       Return[N[  ( 60 Log[1.0787 b / d] + A)/Sqrt[Er]  ] ]
  140.      ] /; NumberQ[N[d]] && NumberQ[N[ww]] && NumberQ[N[bb]] && NumberQ[N[Er]] 
  141.  
  142. Coax[r_, R_, Er_] := 
  143.      Block[{c, l,z},
  144.         c = N[2 Pi  8.8542 10^-12 Er/ Log[R/r]];
  145.         l = N[2 10^-7 Log[R/r]];
  146.         z = Sqrt[l/c];
  147.         Return[{c "F/m",l "H/m",z "Ohms"}]
  148.        ]
  149.        
  150. TwinWire[d_, s_, Er_] :=
  151.       Block[{c,l,z},
  152.       c = N[Pi 8.8542 10^-12 Er / ArcCosh[s/d]];
  153.       l = N[4 10^-7 ArcCosh[s/d]];
  154.       z = Sqrt[l/c];
  155.       Return[{c "F/m",l "H/m", z "Ohms"}]
  156.       ]
  157.  
  158. StripLine[w_, h_, er_] :=
  159.       Block[{z, eeff, f},
  160.       If [w/h <= 1, f = (1 + 12 h /w) ^ -0.5 + 0.04 ((1 - w/h) ^ 2)];
  161.       If [w/h > 1, f = (1 + 12 h /w ) ^ -0.5];
  162.       eeff=0.5 (er + 1) + 0.5 (er - 1 ) f;   (* the effective Er, tacking into account the two
  163. permittivities *)
  164.       If[ w/h < 1, z = N[60*Log[8*(h/w) + 0.25 * (w/h) ] /Sqrt[eeff] ]  ];
  165.       If[ w/h >= 1, z = N[(120 * Pi/ Sqrt[eeff]) * 1/( (w/h + 1.393 + .667 * Log[ w/h + 1.44]))
  166. ]];
  167.       Return[z]
  168.       ]
  169.  
  170. UnknownC[freq_, ZL_, length_, type_]:=
  171.       Block[{c}, 
  172.       If[ ToString[type] == "Short", 
  173.       c = 10^12 Cot[  2 Pi length/ (300/freq)]  / (2 Pi freq 10^6 ZL) ];
  174.       If[ ToString[type] == "Open", 
  175.       c = - 10^12 Tan[  2 Pi length/ (300/freq)]  / (2 Pi freq 10^6 ZL) ];
  176.       Return[N[c]]
  177.       ]
  178.  
  179. TerminatedLine[Zo_,Zl_,B_,l_]:=
  180.       Return[Zo*(Zl Cos[B l] + I Zo Sin[B l])/(Zo Cos[B l] + I Zl Sin[B l])]//N
  181.  
  182. SMESFET[freq_,Zo_,Rs_,Cgs_,Ro_,Co_,gm_]:=
  183.       Block[{w,s11,s12,s21,s22,s, S11, S12, S21, S22},
  184.       w = 2 Pi freq //N;
  185.  
  186.       s11=(w Cgs (Rs-Zo) -I)/(w Cgs (Rs + Zo) -I);
  187.       s12=0;  
  188.       s21=(gm Ro Zo (1+s11))/((1 + I w Cgs Rs)(Zo + Ro + I w Co Zo Ro));
  189.       s22=(Ro-Zo - I w Co Ro Zo)/(Ro + Zo + I w Co Ro Zo);
  190.       
  191. puff={freq/10^9,Abs[s11],Arg[s11]/Degree//N,Abs[s21],Arg[s21]/Degree//N,Abs[s12],Arg[s12]
  192. /Degree//N,Abs[s22],Arg[s22]/Degree//N};
  193.       Return[puff]
  194.       ]
  195. End[]
  196. EndPackage[]
  197.            
  198.